package com.fcl.oschina.ui.activity;

import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.fcl.mylibrary.ImageLoader.ImageLoader;
import com.fcl.mylibrary.reflect.OnClick;
import com.fcl.mylibrary.reflect.ViewInject;
import com.fcl.mylibrary.util.StringUtil;
import com.fcl.oschina.Constant;
import com.fcl.oschina.R;
import com.fcl.oschina.entity.DetailResult;
import com.fcl.oschina.model.DetailModel;

import de.hdodenhof.circleimageview.CircleImageView;

public class BlogDetailActivity extends DetailActivity {

    private String TAG = "BlogDetailActivity";
    private int mId;
    private String mType = "blog";
    private DetailModel mDetailModel;

    @ViewInject(R.id.user_avtar)
    CircleImageView mUserAvtar;

    @ViewInject(R.id.user_name)
    TextView mUserTv;

    @ViewInject(R.id.date)
    TextView mDateTv;

    @OnClick({R.id.user_avtar})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.user_avtar:
                Intent intent = new Intent(BlogDetailActivity.this, UserInfoActivity.class);
                intent.putExtra("id", mDetail.getAuthorId());
                startActivity(intent);
                break;
        }
    }

    @Override
    public void setDetail(DetailResult detail) {
        super.setDetail(detail);
        mUserTv.setText(detail.getAuthor());
        mDateTv.setText(StringUtil.formatSomeAgo(detail.getPubDate()));
        ImageLoader.getInstance().loadImage(detail.getAuthorPortrait(),mUserAvtar,true);
    }

    @Override
    protected int getTitleInt() {
        return R.string.blog_detail;
    }

    @Override
    protected String getType() {
        return "blog";
    }

    @Override
    protected int getTypeNum() {
        return Constant.COMMENT_BLOG;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_blog_detail;
    }


}
